package org.easy.minimaxi;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;


@Configuration
@EnableConfigurationProperties({MinimaxiProperties.class})
@ConditionalOnProperty(prefix = MinimaxiProperties.PREFIX, name = "enabled", havingValue = "true")
public class MinimaxiAutoConfiguration {

    @Resource
    private MinimaxiProperties minimaxiProperties;

    @Bean
    public MinimaxiTemplate minimaxiTemplate() {
        return new MinimaxiTemplate(new MinimaxiClient(minimaxiProperties.getApikey()));
    }

}
